<template>
  <div>
    <div class="content">
      <div class="search">
        <div class="search-d1">
          <i class="fi fa fa-search" aria-hidden="true"></i>
          <span class="search-text">搜索鲜花、永生花、礼品</span>
        </div>
      </div>
      <div class="menu-left fl">
        <ul>
          <li
            v-for="(item,index) in list"
            :key="item"
            v-cloak
            ref="list"
            @click="huan(index,$event)"
          >{{item}}</li>
        </ul>
      </div>
      <!-- 组件 -->
      <div class="menu-right fl">
        <ClassifyRight ref="mychild" />
      </div>
    </div>
  </div>
</template>
<script>
const ClassifyRight = () => import("@/components/Classify-right.vue");
export default {
  data() {
    return {
      list: [
        "鲜花用途",
        "节日送花",
        "鲜花花材",
        "鲜花类别",
        "鲜花支数",
        "鲜花颜色",
        "对象送花",
        "花篮用途",
        "绿植类别",
        "绿植名称",
        "绿植类型",
        "绿植用途",
        "鲜花品质"
      ]
    };
  },
  components: {
    ClassifyRight
  },
  methods: {
    huan(index, ev) {
      for (let i = 0; i < this.lists.length; i++) {
        this.lists[i].className = "";
      }
      this.lists[index].className = "active";
      this.$refs.mychild.classifydata(ev.target.innerHTML);
    }
  },
  mounted() {
    this.lists = this.$refs.list;
    this.lists[0].className = "active"; //一打开就是第一个高亮
  }
};
</script>
<style scoped lang="scss">
@function vw($px) {
  @return ($px / 375) * 100vw;
}
[v-cloak] {
  display: none;
}
.content {
  .search {
    box-sizing: border-box;
    height: vw(50);
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: vw(1) solid #f2f2f2;
    .search-d1 {
      height: vw(34);
      width: vw(355.2);
      background-color: #f2f2f2;
      border-radius: vw(50);
      line-height: vw(34);
      .fi {
        font-size: vw(15);
        margin: 0 vw(12);
        color: rgb(143, 136, 136);
      }
      .search-text {
        font-size: vw(12);
      }
    }
  }
  .menu-left {
    width: vw(100);
    background-color: #f8f8f8;
    ul {
      li {
        text-align: center;
        height: vw(40.8);
        line-height: vw(40.8);
        font-size: vw(14);
      }
    }
  }
  .menu-right {
    width: vw(275);
  }
}

.active {
  background-color: #fff;
  color: #f46;
}
</style>